
import { ccs } from "../../util/services";
import { BagM } from "../control/bag/bagM";
import { game } from "../control/game";
import { companyBase } from "../control/Item/ItemBase";
import { assetsType, companyType, diseaseType, edu, hospitalType, playerType, studyModel } from "../gameType";


export default class heroBase {
    
    heroInfo: playerType = null;
    bag: BagM = null;
    ads = [5,5,5,5];
    constructor(player?: playerType, bag?: boolean) {
        this._init(player, bag);
    }
    getMoney() {
        return this.heroInfo.money;
    }
    equipAssets(assets: assetsType, type: string) {
        if(this.heroInfo[type]) {
            this.changeEffect(this.heroInfo[type].effect, -1);
        }
        this.heroInfo[type] = assets;
        this.changeEffect(this.heroInfo[type].effect, 1);
        ccs.mainEmitter.emit("updateAttribute");
        ccs.mainEmitter.emit("updateAssets");
    }
    //获取技能信息
    getWorkById(id) {
        return this.heroInfo.works.find(val => val.id == id);
    }
    //成就系统
    achieveFinish(id: string, target: number) {
        let achieve = this.heroInfo.achieve.filter(val => val.id == id);
        achieve.forEach(val => {
            if(val.id == "money") {
                val.cur = this.heroInfo.money;
            } else{
                val.cur += target;
            }
            if(val.cur >= val.target && val.state == 0){
                val.age = this.heroInfo.age;
                ccs.mainEmitter.emit("reAchieve");
            }
        })
    }
    changeEffect(effect: Object, sort?: number) {
        if(!sort) {
            sort = 1;
        }
        let arr = ['iq', "learn"];
        let maxCount = 100;
        for(let key in effect) {
            if(key == "iq" || key == 'eq' || key == 'power' || key == 'maxPower') {
                maxCount = 300;
            } else if(key == 'lifeTime') {
                maxCount = 1200;
            } else {
                maxCount = 100;
            }
            if(key == "money") {
                this.calMoney(effect[key]);
            } else {
                this.heroInfo[key] = ccs.gf.handlerCount(this.heroInfo[key], sort * effect[key], maxCount);
                if(arr.indexOf(key) != -1) {
                    this.achieveFinish(key, sort * effect[key]);
                }
            }
        }
        
        ccs.mainEmitter.emit("updateAttribute");
    }
    inverst(data: companyType) {
        
        if(data.isLock) {
            return ccs.winMgr.showWin("toast", {msg: "您已被该行业拉入黑名单"});
        }
        if(!this.calMoney(-data.inverst)) {
            return ccs.winMgr.showWin("toast", {msg: "金钱不足"});
        }
        this.bag.companyBag.addItem(new companyBase(data));
        if(this.bag.companyBag.bag.items.length >= 4) {
            this.achieveFinish("company", 1);
        }
    }
    //每个月的更新数据
    reduceMonth() {
        if(this.heroInfo.school && this.heroInfo.school.state == 1) {
             //增加压力
             this.heroInfo.pressure = ccs.gf.handlerCount(this.heroInfo.pressure, this.heroInfo.school.pressure, 100);
        }
    }
    //生成个人信息
    randomInfo(age?: number, data?: Partial<playerType>) {
        let figureList = ccs.dataMgr.getFigure(0, 200);
        let figure = figureList[Math.floor(Math.random()*200)];
        this.heroInfo.name = figure.name; //名字
        this.heroInfo.money = figure.money; //金钱
        if(age) {
            this.heroInfo.age = age;
        }
        if(data) {
            for(let key in data) {
                this.heroInfo[key] = data[key];
            }
        }
        let maxEdu = ccs.dataMgr.getEduByAge(this.heroInfo.age);
        this.heroInfo.edu = ccs.dataMgr.getJsonData("edu")[ccs.gf.randomInt(0, edu[maxEdu.id])];
        let eduIdx = edu[this.heroInfo.edu.id];
        if(this.heroInfo.age >= 16) {
            this.randomWork();
        }
        //计算年龄和寿命
        this.heroInfo.lifeTime = 1200 - (12 * this.heroInfo.age);
        this.heroInfo.learn = Math.trunc(Math.random() * (this.heroInfo.age >= 30? 30: this.heroInfo.age)) +  eduIdx * 4;
        //魅力，一个学籍加5分
        this.heroInfo.charm += eduIdx * 7;
        this.heroInfo.maxPower = ccs.gf.randomInt(this.heroInfo.age * 8, 300);
        this.heroInfo.power = this.heroInfo.maxPower;
        this.heroInfo.iq = Math.trunc(Math.random() * (22 + this.heroInfo.age)) + eduIdx * 3 + 50;
        if(this.heroInfo.age <= 30) {
            this.heroInfo.eq = Math.trunc(Math.random() * (80 + this.heroInfo.age) + eduIdx * 3);
        } else if(this.heroInfo.age > 30){
            this.heroInfo.eq = Math.trunc(Math.random() * (80 + this.heroInfo.age)) + eduIdx * 3 + 30;
        }
        //获取最大的教育程度
    }
    // 获得零花钱
    getPocketMoney() {
            if(game.playerMgr.heroInfo.age >= 23) {
                return ;
            }
            //一定概率给零花钱
            let hero = game.playerMgr.bag.figureBag.getItem(this.heroInfo.relation.father.id);
            let monther = game.playerMgr.bag.figureBag.getRelation("monther")[0];
            let percent =  Math.random();
            let money = 0;
            if(percent <= hero.data.intimate/100 && hero.data.hero.lifeTime > 100 && hero.data.hero.money > 1000) {
                money += Math.random()* 0.05 * hero.data.hero.work.income;
                hero.data.hero.money -= money;
            }else if( percent <= monther.data.intimate/100 && monther.data.hero.lifeTime > 100 && hero.data.hero.money > 1000){
                money += Math.random()* 0.05 * monther.data.hero.work.income;
                monther.data.hero.money -= money;
            }
            if(money <= 0) {
                return ;
            }
            this.calMoney(money);

            game.recordMgr.addList({action: `你获得了零花钱${money}元`});
    }
    randomWork(level?, index?) {
        let maxEdu = ccs.dataMgr.getEduByAge(this.heroInfo.age); //最大的教育
        let eduIdx = edu[this.heroInfo.edu.id];
        let workIndex = 0, workLevel = 1; 
        workIndex = index || ccs.gf.randomInt(0, eduIdx);
        workLevel = level || ccs.gf.randomInt(1, -4 + eduIdx <= 0? 3: -3 + eduIdx);
        if(this.heroInfo.age >= 16 && (!this.heroInfo.school|| maxEdu.id == 'wu' || edu[maxEdu.id] > eduIdx)) {
            this.heroInfo.work = this.heroInfo.works[workIndex];
            this.heroInfo.work.level = workLevel;
            this.heroInfo.work.gains.forEach((val,index) => {
                if(index <= workLevel - 1) {
                    this.heroInfo.work.income = this.heroInfo.work.income * (1 + val); //月收入计算
                }
            })
            if(game.playerMgr.isFamily(this.heroInfo.id)) {
                game.recordMgr.addList({name: this.heroInfo.name, action: `找到工作了，目前是${this.heroInfo.work.levelName[this.heroInfo.work.level]}`});
            }
        }
    }
    goHospital(disease: diseaseType, family?: boolean, myHospital?: hospitalType) {
        //带人去看病 // 默认去最低级别的医院
        let hospital = null;
        if(!myHospital) {
            hospital = ccs.dataMgr.getHospitalByLevel(disease.level);
        } else {
            hospital = myHospital;
        }
        let cost = hospital.money * disease.cost;
        if(family) {
            if(game.playerMgr.getFamilyMoney() >= cost) {
                game.playerMgr.familyPay(cost);
            }else {
                game.recordMgr.addList({action: `家里想去看病，却拿不出钱来`});
                return ;
            }
        }else {
            //如果是你带家里人看病，会查询家庭资产
            // if(myFamily) {
            //     if(this.getFamilyMoney() >= cost) {

            //     }
            // }
            if(!game.playerMgr.calMoney(-cost)){
               ccs.winMgr.showWin("toast", {msg: "金钱不足"});
               return ;
            }
        }
        
        if(Math.random() <= hospital.percent) {
            this.heroInfo.disease.splice(this.heroInfo.disease.findIndex(val => val.id == disease.id), 1);
            game.recordMgr.addList({action: `${this.heroInfo.name}治疗成功，工作也别忘了锻炼身体哦`});
            this.heroInfo.health = 50;
            ccs.mainEmitter.emit('reDisease');
        } else{
            game.recordMgr.addList({action: `${this.heroInfo.name}治疗失败，病情恶化了`, effect: `寿命 - ${disease.hurt}`});
            this.reduceTime(-disease.hurt);
            this.heroInfo.health = 20;
        }
    }
    //减少寿命`
    reduceTime(time: number) {
        this.heroInfo.lifeTime = ccs.gf.handlerCount(this.heroInfo.lifeTime, time, 1200);
        if(this.heroInfo.lifeTime <= 0 ) {
            game.recordMgr.addList({action: this.heroInfo.name + "的生命结束了"});
            if(this.isPlayer(this.heroInfo.id)) {
                ccs.winMgr.showWin("popAlert", {title: "入土为安", content: `你的结束了短暂的一生，繁华落尽，落叶归根，享年${this.heroInfo.age}岁，重新投胎吗？（退出游戏重开）`, cb: () => {
                    cc.game.end();
                }, 
                cancel: () => {
                    cc.game.end();
                }});
                return ;
            }
            let father = game.playerMgr.bag.figureBag.getRelation("father")[0].data.hero,
            monther = game.playerMgr.bag.figureBag.getRelation("monther")[0].data.hero;
            if(father.id == this.heroInfo.id || monther.id == this.heroInfo.id) {
                //父母亲
                game.playerMgr.calFamily();
            }
            //死亡
            ccs.mainEmitter.emit("updateLife");
        }
        
    }
    calFamily() {
        //继承遗产
        //父亲死亡
        let father = this.bag.figureBag.getRelation("father")[0].data.hero,monther = this.bag.figureBag.getRelation("monther")[0].data.hero;
        let money = monther.money + father.money;
        if(father.lifeTime <= 0) {

            if(monther.lifeTime <= 0) {
                this.calMoney(money);
                game.recordMgr.addList({action: "你含泪继承了遗产" + ccs.gf.getOmitNum(money)})
                father.money = 0;
                monther.money = 0;
            } else {
                monther.money = money;
                father.money = 0;
            }
        }else if(monther.lifeTime <= 0) {
            if(father.lifeTime <= 0) {
                this.calMoney(money);
                game.recordMgr.addList({action: "你含泪继承了遗产" + ccs.gf.getOmitNum(money)})
                father.money = 0;
                monther.money = 0;
            } else {
                father.money = money;
                monther.money = 0;
            }
        }
    }
    _init(player, bag?: boolean) {
        if(player) {
            this.heroInfo = player;
        }else {
            this.heroInfo = {
                name: "string",
                id: ccs.gf.randomId(),
                age: 1,
                money: 100,
                lifeTime: 1200,//寿命
                health: 100, //健康程度
                products: [], //产业
                work: null,
                sex: "b1",
                works: ccs.dataMgr.getJsonData("workType"),
                family: [], //家庭
                incomeMonth: 0, // 月收入
                incomeYear: 0, //年收入
                payMonth: 0,
                assetsPayMonth: 0,
                assetsIncomeMonth: 0,
                payYear: 0,
                rank: {
                    id: 1,
                    star: 0,
                },
                pressure: 0, 
                learn: 1, //学习能力
                charm: 0,
                power: 25,
                maxPower: 25,
                iq: ccs.gf.randomInt(70, 112),
                eq: 1, 
                traffic: null,
                school: null,
                edu: ccs.dataMgr.getJsonData("edu")[0],
                skill: null,//技能
                house: null,
                rent: 2800, //每个月房租
                relation: {
                    chat: null,
                    wife: null,
                    love: null,
                    father: null,
                    monther: null,
                    list: [],
                },
                disease: [],
                achieve: ccs.dataMgr.getAchieveList(),
                companyList: ccs.dataMgr.getCompanyList(),
            }
            if(bag) {
                this.bag = new BagM(); //背包
            }
        }
    }
    //生病
    diseaseReduceTime() {
        let life = 0;
        this.heroInfo.disease.forEach(val => {
           life += val.hurt;
        })
        if(life > 0) {
            this.reduceTime(-life);
            game.recordMgr.addList({action: `${this.heroInfo.name} 生病了，身体越来越虚弱了`, effect: `寿命减少${life * 30}天`});
        }
        
    }
    addYear() {
        //教育成长
        if(this.heroInfo.school && this.heroInfo.school.state == 1) {
            this.changeEffect(this.heroInfo.school.learn, 1);
        }
        this.heroInfo.age += 1;
        this.heroInfo.charm += 0.2;
        this.heroInfo.learn += 0.2;
        //体力成长
        if(this.heroInfo.age <= 10) {
            this.heroInfo.maxPower += 5;
        } else if(this.heroInfo.age > 10 && this.heroInfo.age <= 17){ 
            this.heroInfo.maxPower += 15;
        }else if(this.heroInfo.age > 18 && this.heroInfo.age <= 25) {
            this.heroInfo.maxPower += 5;
        } else if(this.heroInfo.age > 25 && this.heroInfo.age <= 30) {
            this.heroInfo.maxPower -= 2;
        } else if(this.heroInfo.age > 30 && this.heroInfo.age <= 45) {
            this.heroInfo.maxPower -= 3;
        } else if(this.heroInfo.age > 45 && this.heroInfo.age <= 70) {
            this.heroInfo.maxPower -= 5;
        } else if(this.heroInfo.age > 70 && this.heroInfo.age <= 80) {
            this.heroInfo.maxPower -= 10;
        } else if(this.heroInfo.age > 80) {
            this.heroInfo.maxPower -= 15;
        }
        //自然成长
        if(this.heroInfo.age > 5 && this.heroInfo.age <= 10) {
            this.heroInfo.eq += 1;
        } else if(this.heroInfo.age > 10 && this.heroInfo.age <= 30) {
            this.heroInfo.eq += 2;
        } else if(this.heroInfo.age > 30 && this.heroInfo.age <= 60) {
            this.heroInfo.eq += 1;
            this.heroInfo.iq -= 0.5;
        } else if(this.heroInfo.age > 70 ) {
            this.heroInfo.eq += 2;
            this.heroInfo.iq -= 1;
        }
        if(this.heroInfo.eq >= 300) {
            this.heroInfo.eq = 300;
        }
        if(this.heroInfo.iq >= 300) {
            this.heroInfo.iq >= 300;
        }
        if(this.heroInfo.maxPower < 0) {
            this.heroInfo.maxPower = 0;
        }
        if(this.heroInfo.iq < 0) {
            this.heroInfo.iq = 0;
        }
        if(this.heroInfo.learn >= 300) {
            this.heroInfo.learn = 300;
        }
    }
    //生病
    getDisease() {
        let weight = [40,60,85,95,100];
        //健康太低和压力太大都会导致生病
        let hero = this.heroInfo;
        //不健康和压力大容易引发高级病症
        let percent = (100 - hero.health  + hero.pressure)/400;
        let disease: diseaseType = null, num = Math.random();
        if(num <= percent) {
            //生病
            let num = Math.random() * 100;
            weight.concat(num).sort((a, b) => a - b);
            disease = ccs.dataMgr.getDiseaseByLevel(weight.findIndex(val => val == num));
        }
        if(disease && (this.heroInfo.disease.findIndex(val => val.id === disease.id) == -1)) {
            if(this.heroInfo.disease) {
                this.heroInfo.disease.push(disease);
            } else {
                this.heroInfo.disease = [disease];
            }
            if(hero.id == game.playerMgr.heroInfo.id) {
                ccs.winMgr.showWin('toast', {msg: `你不小心患上了${disease.name}，请及时治疗`});
                this.achieveFinish('disease', 1);
            }
            game.recordMgr.addList({'action': `${hero.name} 患上了${disease.name},痛苦万分`});
        }
        
    }
    //人物得病一定的概率
    relationDisease() {
        if(this.heroInfo.disease.length > 0) {
            //去看病
            if(Math.random() > 0.6) {
                this.goHospital(this.heroInfo.disease[0], true);
            }
            return;
        }
        let weight = [40,60,85,95,100];
        let disease: diseaseType = null;
        let percent = (this.heroInfo.age)/400;
        if(Math.random() > percent) {
           return ;
        }
        let num = Math.random() * 100;
        let arr = weight.concat(num).sort((a, b) => a - b);
        let level = arr.findIndex(val => val == num);
        disease = ccs.dataMgr.getDiseaseByLevel(level == 0? 1: level);
        let idx = this.heroInfo.disease.findIndex(val => val.id === disease.id);
        if(disease && idx == -1) {
            if(this.heroInfo.disease) {
                this.heroInfo.disease.push(disease);
            } else {
                this.heroInfo.disease = [disease];
            }
            game.recordMgr.addList({'action': `${this.heroInfo.name} 患上了${disease.name},痛苦万分`});
        }
    }
    //成长 每个月
    groupUp() {
        //人物成长
        if(this.bag) {
            this.bag.figureBag.addMonth();
        }
    }
    getWork() {
        if(this.heroInfo.work){
           return this.heroInfo.works.find(val => val.id == this.heroInfo.work.id);
        }
    }
    familyPay(money: number) {
        if(this.getFamilyMoney() > money) {
            let leftCount = money;
            let monther = this.bag.figureBag.getRelation("monther")[0];
            let father = this.bag.figureBag.getRelation("father")[0];
            if(father.data.hero.money >= money) {
                father.data.hero.money -= money;
            }else {
                leftCount =  Math.abs(money - father.data.hero.money);
                father.data.hero.money = 0;
                monther.data.hero.money -= leftCount;
            }
            game.recordMgr.addList({action: `家庭支出 ${money}，剩余资产: ${this.getFamilyMoney()}，父亲${father.data.hero.money}，母亲: ${monther.data.hero.money}`});
            return true;
        } else {
           return false;
        }

    }
    getSchool() {
        if(this.heroInfo.school && this.heroInfo.school.state == 1) {
            return this.heroInfo.school;
        }
        return null;
    }
     //计算学校
     calSchool() {
        if(this.heroInfo.school && this.heroInfo.school.state == 1) {
            //计算一年的成长
            this.heroInfo.school.leftYear --;
            if(this.heroInfo.school.leftYear <= 0) {
                let edu = ccs.dataMgr.getEduById(this.heroInfo.school.type);
                game.recordMgr.addList({name: this.heroInfo.name, action: "毕业了"});
                this.heroInfo.edu = edu;
                ccs.mainEmitter.emit('refreshCard');
                if(edu.type == "boshi") {
                    this.achieveFinish("edu", 1);
                }
                if(this.heroInfo.school.work != 0) {
                  let work = this.heroInfo.works.find(val => this.heroInfo.school.work == val.id);
                  work.level ++;
                }
                this.heroInfo.school = null;
                this.heroInfo.eduScore = 0;
            } else {
                let go = this.familyPay(this.heroInfo.school.price);
                if(!go) {
                    game.recordMgr.addList({name: this.heroInfo.name, action: `交不起学费，你被退学了，需要找更合适的学校`});
                    this.heroInfo.school.state = 0;
                    ccs.winMgr.showWin("popAlert", { content: "是否自费上学？", cb: () => {
                        if(this.heroInfo.school.price > this.heroInfo.money) {
                           ccs.winMgr.showWin("toast", {msg: "金钱不足，可以通过父母获得"});
                            this.heroInfo.school = null;
                        //    return ;
                        } else {
                            this.calMoney(-this.heroInfo.school.price);
                            this.heroInfo.school.state = 1;
                            game.recordMgr.addList({name: "你", action: "自己掏钱交了学费", effect: "钱 -" + this.heroInfo.school.price});
                        }
                        ccs.mainEmitter.emit("updateSchool");
                    }, cancel: () => {
                        this.heroInfo.school = null;
                        ccs.mainEmitter.emit("updateSchool");
                    }});
                } else {
                    game.recordMgr.addList({name: this.heroInfo.name, action: `父母交了学费`, effect: `资产- ${this.heroInfo.school.price}`});
                }
            }
        } else {
            ccs.mainEmitter.emit("updateSchool");
        }
    }
    getFamilyMoney() {
        let money = 0, father = this.bag.figureBag.getRelation("father");
        let monther = this.bag.figureBag.getRelation("monther");
        money += father[0].data.hero.money;
        money += monther[0].data.hero.money;
        return money;
    }
    //升职加薪的可能
    getPromotionEff() {
        let randomEff = 0.1;
        let idx = edu[this.heroInfo.edu.id];
        if(this.heroInfo.work.level <= 3) {
           randomEff += idx * 0.1;
       } else if(this.heroInfo.work.level > 4 && this.heroInfo.work.level <= 7) {
           randomEff += idx * 0.05;
       } else if( this.heroInfo.work.level > 8 && this.heroInfo.work.level <= 9) {
           randomEff += idx * 0.03;
       } else {
           randomEff += idx * 0.01;
       }
       return randomEff;
   }
   //职业晋升
   promotion() {
       if(!this.heroInfo.work) {
           return;
       }
       let eff = this.getPromotionEff();
       if(Math.random() <= eff) {
           //可以升职
           let work =this.heroInfo.work;
           work.level ++;
           work.income = work.income * (1 + work.gains[work.level - 1]);
           this.heroInfo.incomeMonth = work.income; //月收益更新
       }
   }
   getPayMonth() {
       return this.heroInfo.payMonth + this.heroInfo.assetsPayMonth;
   }
   getIncomeMonth() {
        return this.heroInfo.incomeMonth + this.heroInfo.assetsIncomeMonth;
   }
    calMoney(money: number): boolean {
        if(isNaN(money)){
            return false;
        }
        if(money < 0 ) {
            if(this.heroInfo.money < Math.abs(money)) {
                // ccs.winMgr.showWin("popAlert", {content: "金钱不足,是否观看广告获取财富",cb: () => {
                //     ccs.AD.showAd((res) => {
                //         if(res) {
                //             this.calMoney(20000);
                //         }
                //     })
                // }});
                ccs.winMgr.showWin('toast', {msg: "钱包有点羞涩"});
                return false;
            }
            this.heroInfo.payMonth += Math.abs(money);
        } else {
            this.heroInfo.incomeMonth += money;
        }
        this.heroInfo.money += money;
        this.achieveFinish("money", money);
        ccs.mainEmitter.emit("updateInfo");
        ccs.mainEmitter.emit("updateAttribute");
        return true;
    }
    //升职
    addExp() {
        
        if(!this.heroInfo.work ) return;
        let work = this.heroInfo.works.find(val => val.id == this.heroInfo.work.id);
        if(this.isPlayer(this.heroInfo.id)){
          game.recordMgr.addList({action: `打工获得工资${work.income}元`})
          game.playerMgr.calMoney(work.income);
        }
        work.curExp += ((this.heroInfo.iq + this.heroInfo.eq) * this.heroInfo.learn/100);
        // work.level ++;
        
        if(work.curExp >= work.exp[work.level]) {
            work.level ++;
            if(work.level > 9) {
                work.level = 9;
            }
            work.income += work.income * work.gains[work.level - 1];
            //收入增加
            this.heroInfo.incomeMonth += work.income * work.gains[work.level - 1];
            
            // if(this.isFamily(this.heroInfo.id)) {
                game.recordMgr.addList({name: this.heroInfo.name, action: `升职加薪了，目前职位为${work.levelName[work.level]}`});
            // }
            if(this.isPlayer(this.heroInfo.id)) {
                ccs.mainEmitter.emit("levelUp");
                if(work.income >= 100000) {
                    game.playerMgr.achieveFinish('monthIncome', 1);
                }
            }
        }
    }
    isPlayer(id) {
        return game.playerMgr.heroInfo.id == id;
    }
    getChildPay() {
        let money = 2000;
        if(this.heroInfo.age <= 3) {
            money = 2000;
        } else if(this.heroInfo.age >3 && this.heroInfo.age <= 19) {
            money = 1200;
        } else if(this.heroInfo.age >19 && this.heroInfo.age <= 23) {
            money = 2500;
        }
        return money;
    }
    getSchoolMoney() {
        if(this.heroInfo.school && (this.heroInfo.school.type == 'daxue' || this.heroInfo.school.type == 'yanjiusheng')) {
            this.calMoney(1500);
            this.familyPay(1500);
            game.recordMgr.addList({action: "获得生活费500元"});
        }
    }
    isFamily(id: string | number) {
        let relation = game.playerMgr.heroInfo.relation;
        if((relation.father && relation.father.hero.id == id) || (relation.monther && relation.monther.hero.id == id) || (relation.wife && relation.wife.hero.id == id )|| (relation.love && relation.love.hero.id == id)) {
            return true;
        }
        return false;
    }
    unWork() {
        if(!this.heroInfo.work) return;
        // this.heroInfo.assetsIncomeMonth -= this.getWork().income;
        this.heroInfo.work = null;
    }
}